import {
  reqCarTypeList
} from '@/api/carType'
import {
  reqGetNewPublicity
} from '@/api/publicity'

Page({

  data: {
    publicity: '',
    carList: [],
    showDetails: false,
    carDetail: {},
  },
  toDetails(event) {
    this.setData({
      showDetails: true,
      carDetail: event.detail
    })
  },
  toAddOrder(event) {
    this.setData({
      showDetails: false
    })
    const carStr = JSON.stringify(event.detail)
    wx.navigateTo({
      url: `/pages/order/add/add?carStr=${carStr}`,
    })
  },
  onClose() {
    this.setData({
      showDetails: false
    })
    wx.showTabBar()
  },
  async onShow() {
    await wx.showTabBar()
    const res = await reqCarTypeList()
    const res1 = await reqGetNewPublicity()
    this.setData({
      carList: res.data,
      publicity: res1.data
    })
  },
  onShareAppMessage(){
  },
  onShareTimeline(){
    
  }
})